"""WeChat front matter validator and processor"""

from typing import Any

from .base import BaseFrontMatter
from .validator import ValidationResult


class WeChatFrontMatter(BaseFrontMatter):
    """WeChat front matter class for handling WeChat-specific front matter fields and validation"""

    # Override delimiter for WeChat
    DELIMITER = "+++\n"

    def validate(self) -> ValidationResult:
        """Validate front matter fields

        Returns:
            ValidationResult object containing validation issues
        """
        fields = {
            "title": self.title,
            "draft": self._raw_draft if self._raw_draft is not None else "",
            "description": self.description,
            "banner": self.banner,
            "author": self._raw_author if self._raw_author is not None else "",
            "date": self.date,
        }
        return self.validator.validate_to_result(fields)

    def _register_validation_rules(self):
        """Register WeChat-specific validation rules"""
        # First register base validation rules
        super()._register_validation_rules()

    def auto_completion(self, body_content: str, openrouter_service: Any) -> None:
        """Enhance front matter fields using the provided content and OpenRouter service

        Args:
            body_content: The markdown content to analyze
            openrouter_service: The OpenRouter service instance to use for enhancement
        """
        super().auto_completion(body_content, openrouter_service)
